using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;
using Pay.Core;

namespace Pay.Service.AutoMapper
{
    public class UserRedTransferHisMapper : IStartupDto
    {
        private IMapperConfigurationExpression _cfg;
        public UserRedTransferHisMapper(IMapperConfigurationExpression cfg)
        {
            _cfg = cfg;
        }
        public void Execute()
        {
            Create();
        }
        protected virtual void Create()
        {
            _cfg.CreateMap<UserRedTransferHis, user_red_transfer_his>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.user_id, src => src.MapFrom(c => c.UserId))
                .ForMember(dest => dest.receive_user_id, src => src.MapFrom(c => c.ReceiveUserId))
                .ForMember(dest => dest.amount, src => src.MapFrom(c => c.Amount))
                .ForMember(dest => dest.fee_rate, src => src.MapFrom(c => c.FeeRate))
                .ForMember(dest => dest.fee, src => src.MapFrom(c => c.Fee))
                .ForMember(dest => dest.create_time, src => src.MapFrom(c => c.CreateTime.ToDateTime()))
                .ForMember(dest => dest.is_show_transfer_out, src => src.MapFrom(c => c.IsShowTransferOut))
                .ForMember(dest => dest.merchant, src => src.MapFrom(c => c.User.ToDtoObject<merchant_dto>()))
                .ForMember(dest => dest.receiver, src => src.MapFrom(c => c.Receiver.ToDtoObject<merchant_dto>()));


        }
    }
}
